package homework03.test01;

public class Test01 {

    public static void main(String[] args) {

        int[] arr = null;
        System.out.println(toString(arr));

        int[] arr1 = {};
        System.out.println(toString(arr1));

        int[] arr2 = {1, 2, 3, 4, 5};
        System.out.println(toString(arr2));
    }

    public static String toString(int[] arr) {

        if (null == arr) {
            return "null";
        }

        if (0 == arr.length) {
            return "[]";
        }

        StringBuilder sb1 = new StringBuilder("[");

        for (int i = 0;i < arr.length;i++) {
            if (arr.length - 1 == i) {
                sb1.append(arr[i]).append("]");
            } else {
                sb1.append(arr[i]).append(", ");
            }
        }

        return sb1.toString();
    }
}
